//Source file: E:\\projects\\graph_viewer\\graph_viewer\\drawer\\Node_Drawer.java

package graph_viewer.drawer;

import java.awt.*;
import java.util.*;


import graph_viewer.structure.*;
import graph_viewer.util.*;

/**
	Define method to draw a node, the drawing is done by Node_Drawer_Handler in subclasses.
*/
public class Focus_Drawer extends Basic_Node_Drawer{
	boolean has_label, has_DOI;

	public Focus_Drawer(){
		set_has_DOI( false );
		set_has_label( false );
	}

	public Focus_Drawer( boolean has_label, boolean has_DOI ){
		set_has_DOI( has_DOI );
		set_has_label( has_label );
	}

	public Focus_Drawer( boolean has_label ){
		set_has_DOI( false );
		set_has_label( has_label );
	}

	public void set_has_DOI( boolean has ){
		has_DOI		= has;
	}

	public void set_has_label( boolean has ){
		has_label	= has;
	}
		
	public boolean get_has_DOI(  ){
		return has_DOI;
	}

	public boolean get_has_label(  ){
		return has_label;
	}
	
	protected void draw_node( Node node, Graphics2D g, int k ){		
		Node_Position	np = node.get_position();		
		int[] location 	= np.find_location();
		
		g.setColor( FOCUS_COLOR );
		g.fillRect( location[0], location[1], np.get_width() + 1, np.get_height() + 1 );
		
		g.setColor( Color.black );
		g.drawRect( location[0], location[1], np.get_width(), np.get_height() );		
	}

	// reimplement draw_node_label
	/*protected void draw_node_label( Node node, final Graphics2D g ){
		if ( !has_label ){
			return;
		}

		int[]	location	= node.get_position().find_location();		
		String label	=Drawer_Util.get_displayed_label( node );

		g.setColor( Color.black );
		g.drawString( label, location[0]  + 5 , location[1] + node.get_position().get_height() - 5 ); // +1 to set the margin
	}*/

	//@return first element = brief_text: first token
	private ArrayList parse_text( Node a_node ){
		String
			brief_txt = new String( a_node.get_brief_text() ),
			txt			= new String( a_node.get_text() );

		ArrayList parsed_text = new ArrayList();

		StringTokenizer st = new StringTokenizer( txt, Visual_Component.NODE_TEXT_SET );

		int index = 0;
		while ( st.hasMoreTokens() ){
			String t = st.nextToken();
			if ( index == 0 ){
				t = brief_txt + ": " + t;
				//parsed_text.add( brief_txt);
				parsed_text.add( ":"  + t );
			}else
				parsed_text.add(t.trim() );
			index++;
		}
		
		
		return parsed_text;
	}
}
